#include<iostream>
#include<cstring>

using std::cin;
using std::cout;
using std::endl;

int reverse_str(char *str);

int check();

int main()
{
    int ret;
    ret=check();
    return ret;   
}

int check()
{
    char str[1024];
    int num_cases;
    cin>>num_cases;
    cin.ignore();
    for(int i=0; i<num_cases;i++)
    {
        memset(str,0,1024);
        cin.getline(str,1024);
        if(1==reverse_str(str))
        {
            return 1;
        }
        for(int i=0; i<strlen(str);i++)
            cout<<str[i];
        cout<<endl;
    }
    return 0;
}

int reverse_str(char *str)
{
/*
    Parameters: 
    1.str(In & Out), the string to be reversed.
    
    Return value:
    Return 1, if there is an error in this function.
    Return 0, if there is no error in this function.

    Logic:
    1. Find the middle position. change the i-th and size-ith variable.
    2. Change the middle and middle+1 variable, if the size is an even.
*/
    size_t num;
    size_t pre,post;
    size_t mid;
    char temp;

    num=strlen(str);
    if(0==num)
    {
       // cout<<"The string is empty, So the reversed one is still the original string."<<endl;
        return 0;
    }
    pre=0;
    post=num-1;
    mid=(pre+post)/2;
    
    while(pre!=mid)
    {
        temp=*(str+pre);
        *(str+pre)=*(str+post-pre);
        *(str+post-pre)=temp;
        pre++;
    }
    if(0==num%2)
    {
        temp=*(str+mid);
        *(str+mid)=*(str+mid+1);
        *(str+mid+1)=temp;
    }
    return 0;
}
